package com.jiamao.goplay.ui.user.vm;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;

import com.jiamao.goplay.ui.photo.PhotoViewFragment;

import java.util.ArrayList;

import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.base.MultiItemViewModel;
import me.goldze.mvvmhabit.binding.command.BindingAction;
import me.goldze.mvvmhabit.binding.command.BindingCommand;

public class MePhotoItemVM extends MultiItemViewModel {

    public ObservableField<String> imgUrl = new ObservableField<>("");
    public ObservableField<Integer> isDefaul = new ObservableField<>(0);
    private ArrayList<String> imgList;
    private int pos=0;
    public MePhotoItemVM(@NonNull BaseViewModel viewModel,com.jiamao.goplay.bean.AvatarList avatarList,ArrayList<String> list,int i) {
        super(viewModel);
        imgList = list;
        this.pos = i;
        if (avatarList!=null){
            imgUrl.set(avatarList.getUrl());
        }

    }

    //条目的点击事件
    public BindingCommand itemClick = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            
            if (imgList == null){
                imgList = new ArrayList<>();
                imgList.add(imgUrl.get());
            }
            Bundle bd = new Bundle();
            bd.putStringArrayList("list",imgList);
            bd.putInt("index",pos);
            viewModel.startContainerActivity(PhotoViewFragment.class.getCanonicalName(),bd);
           // viewModel.startContainerActivity(SearchFragment.class.getCanonicalName());
        }
    });
}
